package com.qf.controller;

import com.qf.impl.PayServie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author H
 * @create 2020-11-03 22:58
 * @strive To be whoever you want to be.
 * @Description:
 */
@RestController
public class PayController {
    @Autowired
    private PayServie payServie;

    //http://localhost:8015/pay/?payableAmountTotal= 10000 自己填
    //6216261000000000018 银行卡
    //341126197709218366  身份证
    //123456  验证码
    //全渠道 姓名
    @RequestMapping("/pay")
    public void pay(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        //@RequestParam Double payableAmountTotal
        System.out.println("pay====================================开始");
        System.out.println("allMoney1==============="+req.getAttribute("allMoney1"));
        resp.setContentType("text/html;charset=utf-8");
        String pay = payServie.pay(req, resp);//payableAmountTotal

        System.out.println("pay====================================payServie.pay执行完成");

        PrintWriter out = resp.getWriter();
        out.println(pay);
        out.close();

    }

    @RequestMapping("/hello")
    public String hello() {
        return "heelo";

    }
}
